import 'package:dio/dio.dart';
import 'package:flutter_mmvm_provider/model/joke_model.dart';
import 'package:flutter_mmvm_provider/viewmodel/joke_view_model.dart';

class Service{
  static Future<void> getjokes(JokeViewModel jokeViewModel) async{
    var response = await Dio().get("http://v.juhe.cn/joke/content/text.php?page=1&pagesize=20&key=03303e4d34effe095cf6a4257474cda9");
    print(response);
    if(response.statusCode == 200){
      JokeModel model = JokeModel.fromJson(response.data);
      print(response.data);
      jokeViewModel.getJokeList(model.result?.data??[]);
    }
  }
}